package com.zc.study.designPattern.创建型设计模式.prototypePattern.prototypeManager;

import java.util.Hashtable;

public class PrototypeManager {
    //定义一个hashtable,用于存储原型对象
    private Hashtable ht = new Hashtable();

    private static PrototypeManager pm= new PrototypeManager();

    //为hashtable增加公文对象
    private PrototypeManager(){
        ht.put("far",new FAR());
        ht.put("srs",new SRS());
    }

    //增加新的公文对象
    public void addOfficalDocument(String key,OfficalDocument off){
        ht.put(key,off);
    }

    //通过浅clone获取公文对象
    public OfficalDocument getDoc(String key){
        OfficalDocument doc = (OfficalDocument) ht.get(key);
        return doc.clone();
    }

    //获取文件管理器的单例对象
    public static PrototypeManager getPm(){
        return pm;
    }
}
